</head>
<body>
<div class="f-sep10"></div>
<div class="f-sep10"></div>
<div class="m-hd m-tabs">
  <h2 class="u-tt">{$action_name}管理组</h2>
  <ul id="tabs">
    <li> <a class="z-crt" href="#tab1">基本信息</a></li>
    <li> <a href="#tab2">功能权限</a></li>
    <li> <a href="#tab3">菜单权限</a></li>
    <li> <a href="#tab4">其他权限</a></li>
	<li><a href="{$url(user_group/index)}">管理组列表</a></li>
  </ul>
</div>
<div class="f-sep10"></div>
<div class="m-form">
  <form action="<?php echo url('user_group/'.$action.'_save'); ?>" method="post" id="form">
    <fieldset>
      <div id="tab1">
        <div class="formitm">
          <label class="lab" >管理组名称：</label>
          <div class="ipt">
            <input name="name" type="text" class="u-ipt" id="name" value="{$info.name}" datatype="s1-20" errormsg="管理组名称至少1~20个字符！" />
            <span class="Validform_checktip"></span> </div>
        </div>
        <!--if:{$user['level']==1}-->
        <div class="formitm">
          <label class="lab" >管理等级：</label>
          <div class="ipt">
            <select name="level" id="level">
              <option value="1" <!--if:{$info['level']==1}--> selected="selected" <!--{/if}--> >一级管理组
              </option>
              <option value="2" <!--if:{$info['level']==2}--> selected="selected" <!--{/if}--> >二级管理组
              </option>
              <option value="3" <!--if:{$info['level']==3}--> selected="selected" <!--{/if}--> >三级管理组
              </option>
            </select>
            <span class="Validform_checktip">低级别将看不到高级别的管理组与所属用户(只有级别等于一级的用户才可设置级别，默认三级用户)</span> </div>
        </div>
        <!--{/if}--> 
      </div>
      <div id="tab2">
        <div class="formitm">
          <label class="lab" >权限选择：</label>
          <div class="ipt">
            <button class="u-btn u-btn-c4" type="button" onClick="selectall('base_purview',1)">全选</button>
            <button class="u-btn u-btn-c4" type="button" onClick="selectall('base_purview',0)">取消</button>
          </div>
        </div>
        <?php
        if(!empty($base_purview)){
            foreach ($base_purview as $key => $app) {
                if(!empty($app)){
                    foreach ($app as $list_mode => $list) {
        ?>
        <div class="formitm">
          <label class="lab" >{$list.name}：</label>
          <div class="ipt">
            <?php if(!empty($list['auth'])){ foreach ($list['auth'] as $action => $vo) { ?>
            <?php $base_purview_array=unserialize($info['base_purview']); if(in_array($key.'_'.$list_mode.'_'.$action,(array)$base_purview_array)){ $checked='checked'; }else { $checked= '' ;} ?>
            <input class="base_purview" name="base_purview[]" {$checked} type="checkbox" value="{$key}_{$list_mode}_{$action}">
            {$vo}&nbsp;&nbsp;
            <?php }} ?>
          </div>
		  <div class="f-cb"></div>
        </div>
        <?php
		             }
                }
            }
        }
             ?>
      </div>
      <div id="tab3">
        <div class="formitm">
          <label class="lab" >权限选择：</label>
          <div class="ipt">
            <button class="u-btn u-btn-c4" type="button" onClick="selectall('menu_purview',1)">全选</button>
            <button class="u-btn u-btn-c4" type="button" onClick="selectall('menu_purview',0)">取消</button>
          </div>
        </div>
        <?php
        if(!empty($menu_purview)){
            foreach ($menu_purview as $name => $menu) {
        ?>
        <div class="formitm">
          <label class="lab" >{$name}：</label>
          <div class="ipt">
            <?php if(!empty($menu)){ foreach ($menu as $vo) { ?>
            <?php $menu_purview_array=unserialize($info['menu_purview']); if(in_array($vo['url'],(array)$menu_purview_array)){ $checked='checked'; }else { $checked= '' ;} ?>
            <input class="menu_purview" name="menu_purview[]" {$checked} type="checkbox" value="{$vo.url}">
            {$vo.name}&nbsp;&nbsp;
            <?php }} ?>
          </div>
		  <div class="f-cb"></div>
        </div>
        <?php }} ?>
      </div>
      <div id="tab4">
        <div class="formitm">
          <label class="lab" >权限选择：</label>
          <div class="ipt">
            <button class="u-btn u-btn-c4" type="button" onClick="selectall('other_purview',1)">全选</button>
            <button class="u-btn u-btn-c4" type="button" onClick="selectall('other_purview',0)">取消</button>
          </div>
        </div>
        <div class="formitm">
          <label class="lab" >列表模型权限：</label>
          <div class="ipt">
            <?php if(!empty($model_purview)){ foreach ($model_purview as $vo) {?>
            <?php $model_purview_array=unserialize($info['model_purview']); if(in_array($vo['model'],(array)$model_purview_array)){ $checked='checked'; }else { $checked= '' ;} ?>
            <input class="other_purview" name="model_purview[]" {$checked} type="checkbox" value="{$vo.model}">
            {$vo.name}&nbsp;&nbsp;
            <?php }} ?>
          </div>
		  <div class="f-cb"></div>
        </div>
        <div class="formitm">
          <label class="lab" >表单权限：</label>
          <div class="ipt">
            <?php if(!empty($form_purview)){ foreach ($form_purview as $vo) {?>
            <?php $form_purview_array=unserialize($info['form_purview']); if(in_array($vo['table'],(array)$form_purview_array)){ $checked='checked'; }else { $checked= '' ;} ?>
            <input class="other_purview" name="form_purview[]" {$checked} type="checkbox" value="{$vo.table}">
            {$vo.name}&nbsp;&nbsp;
            <?php }} ?>
          </div>
        </div>
      </div>
      <div class="formitm formitm-1">
        <button class="u-btn" id="submit" type="submit">保存修改</button>
        <button class="u-btn u-btn-c4" id="reset" type="button">重置</button>
        <span id="tip" class="load"></span> </div>
    </fieldset>
    <input name="gid" type="hidden" value="{$info.gid}" />
  </form>
</div>
</body>
<script>
var selectall = new function(){}; 
Do.ready('base','form','tabs','dialog', function() {
	saveform('{$url(user_group/index)}');
	tabs();
	window.selectall = function selectall(name,type){  
	
		$("."+name).each(function(){
		if(!type){   
			  $(this).removeAttr("checked");   
		}else{   
			  $(this).attr("checked",'true');   
		}   
		})  
	}
});
</script>